from django.core.paginator import Paginator


def page_data(paginator: Paginator, page_num: int, serializer_class):
    page_obj = paginator.get_page(page_num)
    return {
        'total_count': paginator.count,
        'total_pages': paginator.num_pages,
        'current_page': page_obj.number,
        'results': serializer_class(page_obj, many=True).data,
    }
